package com.tianyu.service.base;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tianyu.mapper.ThirdCompanyAccessChannelMapper;
import com.tianyu.model.entity.ThirdCompanyAccessChannel;
import com.tianyu.model.ro.ServiceRo;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**********************************
 * @Author YSW
 * @Description
 * @Date 2024/7/15 - 14:28
 **********************************/

@Slf4j
@Service
public class ThirdCompanyAccessChannelService {

    @Resource
    private ThirdCompanyAccessChannelMapper thirdCompanyAccessChannelMapper;

    public List<ThirdCompanyAccessChannel> getList(){
        return thirdCompanyAccessChannelMapper.selectList(Wrappers.lambdaQuery());
    }
    
    public ThirdCompanyAccessChannel selectByThirdId(String thirdId){
        return thirdCompanyAccessChannelMapper.selectOne(Wrappers.<ThirdCompanyAccessChannel>lambdaQuery()
                .eq(ThirdCompanyAccessChannel::getThirdId, thirdId));
    }

    public ThirdCompanyAccessChannel selectByYkCompanyId(Integer ykCompanyId){
        return thirdCompanyAccessChannelMapper.selectOne(Wrappers.<ThirdCompanyAccessChannel>lambdaQuery()
                .eq(ThirdCompanyAccessChannel::getYkCompanyId, ykCompanyId));
    }

    public ServiceRo<?> updateById(ThirdCompanyAccessChannel thirdCompanyAccessChannel){
        final int update = thirdCompanyAccessChannelMapper.updateById(thirdCompanyAccessChannel);
        return update == 1 ? ServiceRo.resultSuccess() : ServiceRo.resultFailed("更新失败...");
    }

    public ServiceRo<?> insert(ThirdCompanyAccessChannel thirdCompanyAccessChannel){
        final int insert = thirdCompanyAccessChannelMapper.insert(thirdCompanyAccessChannel);
        return insert == 1 ? ServiceRo.resultSuccess() : ServiceRo.resultFailed("更新失败...");
    }
}
